using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient; 

namespace 药品管理系统
{
    public partial class frm_Userquery : Form
    {
        public frm_Userquery()
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;
        }

        private void btn_Load_Click(object sender, EventArgs e)
        {
            SqlConnection sqlConnection = new SqlConnection();                                              
            sqlConnection.ConnectionString =
             "Server=KK的秘密;Database=MMS;Integrated Security=sspi"; 
            sqlConnection.Open();                  
            SqlCommand sqlCommand = new SqlCommand();                                                                                                   
            sqlCommand.Connection = sqlConnection;                                                                    
            sqlCommand.CommandText = "SELECT * FROM tb_user WHERE Uno=@No;";
            sqlCommand.Parameters.AddWithValue("@No", txb_UserNo.Text);                                       
            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter();                                           
            sqlDataAdapter.SelectCommand = sqlCommand;                                                                                                     
            SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                                 
            if (sqlDataReader.Read())                                                                     
            {
                this.txb_Username.Text = sqlDataReader["Uname"].ToString();
                this.rdb_Male.Checked = (bool)sqlDataReader["Usex"];
                this.rdb_Female.Checked = !(bool)sqlDataReader["Usex"];
                this.dtp_BirthDate.Text = sqlDataReader["Udate"].ToString();
                this.txb_Contact.Text = sqlDataReader["Ucontact"].ToString();
            }
            sqlDataReader.Close();                                                                          
        }


        private void frm_Userquery_Load(object sender, EventArgs e)
        {

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            frm_Menu a = new frm_Menu();
            a.Show();
            this.Hide();
        }

        private void 菜单ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_Menu a = new frm_Menu();
            a.Show();
            this.Hide();
        }

        private void 登录ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_Login b = new frm_Login();
            b.Show();
            this.Hide();
        }

        private void 注册ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_Register c = new frm_Register();
            c.Show();
            this.Hide();
        }
    }
}
